#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

bool buddyStrings(char* s, char* goal);

int main()
{
	return 0;
}

bool buddyStrings(char* s, char* goal)
{
	char ch1, ch2;
	int idx1 = -1, idx2 = -1, i, freq[26] = { 0 };
	for (i = 0; (ch1 = s[i]) && (ch2 = goal[i]); i++) {
		freq[ch1 - 'a']++;
		if (ch1 == ch2) continue;
		if (ch1 != ch2) {
			if (idx1 != -1 && idx2 != -1) return false;
			if (idx1 != -1) idx2 = i;
			else idx1 = i;
		}
	}

	if (s[i] || goal[i]) return false;
	if (idx1 != -1 && idx2 != -1) return s[idx1] == goal[idx2]? s[idx2] == goal[idx1]? true: false : false;
	if (idx1 == -1 && idx2 == -1)
		for (int j = 0; j < 26; j++)
			if (freq[j] > 1) return true;
	return false;
}
